<?php
// 定义塔罗牌数组，包含牌名和简单释义
$tarotCards = [
    [
        "name" => "愚者",
        "meaning" => "代表开始、天真、自由、冒险，有新的开始和无限可能，但也可能有些盲目和冲动。"
    ],
    [
        "name" => "魔术师",
        "meaning" => "象征着创造力、智慧、能力，暗示可以运用自身能力达成目标。"
    ],
    [
        "name" => "女祭司",
        "meaning" => "表示智慧、冷静、直觉，意味着要倾听内心声音，挖掘隐藏信息。"
    ],
    [
        "name" => "皇后",
        "meaning" => "代表丰饶、母爱、美丽、和谐，生活各方面会有良好发展。"
    ],
    [
        "name" => "皇帝",
        "meaning" => "象征权威、领导力、秩序，意味着要建立规则和掌控局面。"
    ]
    // 可继续添加更多塔罗牌信息
];

// 处理抽取塔罗牌的请求
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $randomIndex = array_rand($tarotCards);
    $drawnCard = $tarotCards[$randomIndex];
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>塔罗牌网页游戏</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            background-color: #f4e8d7;
            color: #333;
        }

        h1 {
            color: #6b4e3d;
        }

        form {
            margin-top: 20px;
        }

        button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #6b4e3d;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 5px;
        }

        button:hover {
            background-color: #523a2c;
        }

        #result {
            margin-top: 20px;
            padding: 20px;
            background-color: white;
            border-radius: 5px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
            display: inline-block;
        }

        #result h2 {
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <h1>塔罗牌网页游戏</h1>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
        <button type="submit">抽取塔罗牌</button>
    </form>
    <?php
    if (isset($drawnCard)) {
        echo '<div id="result">';
        echo '<h2>您抽到的塔罗牌是：' . $drawnCard["name"] . '</h2>';
        echo '<p>释义：' . $drawnCard["meaning"] . '</p>';
        echo '</div>';
    }
    ?>
</body>

</html>